package builder.tree;

import java.util.HashMap;

public class Node {
	
	private String value;
	private String attrName;
	
	private HashMap<String, Node> children;
	private int childreAttrColumn;
	private String childrenAttrName;

	private Integer objColumn = null;
	private Node parent;
	
	
	private int level = 0;

	public Node() {
	}

	public Node(String attributeName, String valueName) {
		this.setValue(valueName);
		this.setAttrName(attributeName);
	}

	public void addChild(Node node) {
		this.addChild(node.getValue(), node);
	}

	private void addChild(String key, Node node) {
		if (this.getChildren() == null) {
			this.children = new HashMap<String, Node>();
		}
		if (this.getChildren().containsKey(key)) {
			System.out.println("you are replacing the Node for key:" + key);
		}
		this.getChildren().put(key, node);
	}

	public Node getNode(String key) {
		return this.getChildren().get(key);
	}

	public void setValue(String valueName) {
		this.value = valueName;
	}

	public String getValue() {
		return value;
	}

	public void setAttrName(String attrName) {
		this.attrName = attrName;
	}

	public String getAttrName() {
		return attrName;
	}

	public String getChildrenAttrName() {
		return childrenAttrName;
	}

	public void setChildrenAttrName(String attributeName) {
		this.childrenAttrName = attributeName;
	}

	public void setParent(Node node) {
		this.parent = node;
		this.level = node.getLevel() + 1;
	}

	public Node getParent() {
		return parent;
	}

	public int getLevel() {
		return level;
	}

	public HashMap<String, Node> getChildren() {
		return children;
	}

	public void setChildrenAttrColumn(int attrIndex) {
		this.childreAttrColumn = attrIndex;
	}

	public int getChildrenAttrColumn() {
		return childreAttrColumn;
	}

	public void setObjColumn(Integer objColumn) {
		this.objColumn = objColumn;
	}

	public Integer getObjColumn() {
		return objColumn;
	}
}
